'''
Created on Aug 22, 2010

@author: alia
'''

if __name__ == "__main__":
    import sys,os
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))


import yaml

class YamlToObject(yaml.YAMLObject):
    def __init__(self, **kwargs):
        for value in self.kwargs:
            exec('self.%s = %r' % (value, kwargs[value]))
    def CopySelf(self):
        return copy.deepcopy(locals()["self"])
    

class Player(YamlToObject):
    yaml_tag = u'!Player'
    
class Level(YamlToObject):
    yaml_tag = u'!Level'


class NPC(yaml.YAMLObject):
    yaml_tag = u'!NPC'
    def __init__(self, name, tilemapidx, pos, dim, actions):
        self.name = name
        self.tilemapidx = tilemapidx
        self.pos = pos
        self.dim = dim
        self.actions = actions
    
    def speak(self, speaklist):
        print "speak:"+speaklist
    
    def do(self, dolist):
        print "do:"+dolist
    
    def get_action(self, action):
        print "Eval:" +str(self.actions[action])
        return self.actions[action]

def run():
    from lookup import BuildLookupTable
    npcs = BuildLookupTable("", "../data/defs/test.npc") 
    d = yaml.dump(npcs)
    print d
    objs =  yaml.load(d)
    print objs

if __name__ == "__main__":
    run()